import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:jinke/utils/component/filter_view/model/filter_model.dart';

import '../../util.dart';
import 'index.dart';

class FilterView extends StatelessWidget {
  FilterView({
    Key? key,
    required this.list,
  }) : super(key: key);
  final controller = Get.put(FilterViewController());
  final state = Get.find<FilterViewController>().state;
  final List<FilterModel> list;

  @override
  Widget build(BuildContext context) {
    state.list = list;
    return GetBuilder<FilterViewController>(
      builder: (_) {
        return Row(
          key: state.filterKey,
          children: ['排序', '投资金额']
              .asMap()
              .map(
                (key, value) => MapEntry(
                    key,
                    InkWell(
                      onTap: () => controller.actionFilter(key),
                      child: Container(
                        width: Get.width / list.length,
                        height: 40.r,
                        alignment: Alignment.center,
                        child: Row(
                          mainAxisAlignment: MainAxisAlignment.center,
                          children: [
                            Text(
                              value,
                              style: TextStyle(
                                color: ColorsUtil.title,
                                fontSize: 13.sp,
                              ),
                            ),
                            Icon(
                              Icons.arrow_drop_down_rounded,
                              size: 20.r,
                              color: ColorsUtil.content,
                            )
                          ],
                        ),
                      ),
                    )),
              )
              .values
              .toList(),
        );
      },
    );
  }
}
